// index.js
// 获取应用实例
const app = getApp()

Page({
  data: {
   type:0,
   page:1,
   list:[],
   isop: false
  },
  onLoad() {
    var that = this
   that.getList()
  },
  //数据列表
  getList:function(){
    var that = this
    getApp().request({
            url: getApp().api.mch.user.user_footprint,
            method: "GET",
            data: {
                  page: that.data.page,
                  type: that.data.type,
                  is_mch: 1
            },   
            success: function (res) {
              var list = that.data.list
               console.log(res, '数据')
                for(var i =0;i<res.data.list.length;i++){
                  list.push(res.data.list[i])
                  that.setData({
                    list
                })
                }
            }
          });
  },
  tabStatus:function(e){
    var that = this
    that.setData({
      type:e.currentTarget.dataset.type,
      list:[]
    })
    that.getList()
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    var that = this
    that.setData({
      page:that.data.page + 1
    })
    that.getList()
  },
  xiala: function (e) {
    var that = this;
    var index = e.currentTarget.dataset.index;
    that.setData({
      isop:!that.data.isop
    })
  },
  goToChat: function (e) {
    var mch_id = e.currentTarget.dataset.mch_id;
    var to_user_id = e.currentTarget.dataset.to_user_id;
    var to_user_nickname = e.currentTarget.dataset.to_user_nickname;
    wx.navigateTo({
        url: '/kefu/kefu?mch_id=' + mch_id + '&to_user_id=' + to_user_id + '&to_user_nickname=' + to_user_nickname
    })
},
  navigatorGoods: function (e) {
    var id = e.currentTarget.dataset.goods_id
    var goods_type = e.currentTarget.dataset.goods_type
    if (goods_type == 5) {
      wx.navigateTo({
        url: '/pages/integral-mall/goods-info/index?goods_id=' + id,
      })
    }
    if (goods_type == 4) {
      wx.navigateTo({
        url: '/pages/book/details/details?id=' + id,
      })
    }
    if (goods_type == 3) {
      wx.navigateTo({
        url: '/bargain/goods/goods?goods_id=' + id,
      })
    }
    if (goods_type == 2) {
      wx.navigateTo({
        url: '/pages/pt/details/details?gid=' + id,
      })
    }
    if (goods_type == 1) {
      wx.navigateTo({
        url: '/pages/miaosha/details/details?id=' + id
      })
    }
    if (goods_type == 0) {
      wx.navigateTo({
        url: '/pages/goods/goods?id=' + id,
      })
    }
    
  }
})
